//
//  StoneShowMoreViewController.m
//  Globalstone
//
//  Created by 刘建峰 on 16/7/19.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "StoneShowMoreViewController.h"

@interface StoneShowMoreViewController ()
@property (weak, nonatomic) IBOutlet UIView *navView;
@property (weak, nonatomic) IBOutlet UIScrollView *scroView;
@property (weak, nonatomic) IBOutlet UILabel *productAddress;
@property (weak, nonatomic) IBOutlet UILabel *detailAddress;
@property (weak, nonatomic) IBOutlet UILabel *nearAddress;
@property (weak, nonatomic) IBOutlet UILabel *transType;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property(nonatomic,strong)NSString * phone;
@end

@implementation StoneShowMoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViewLayout];
    [self getStoneDetail];
    // Do any additional setup after loading the view.
}


- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroView];
    
    _scroView.contentSize = flexibleSize(CGSizeMake(0, 505), NO);
}

- (IBAction)back:(id)sender {
    [self backBtn];
}

- (IBAction)call:(id)sender {
    [Common callPhone:_phone view:self.view];
}

#pragma mark == 矿山更多详情
- (void)getStoneDetail{
    if (![Common getLoginStatus]) {
        [[AppDelegate sharedAppDelegate]ShowLoginPage];
        return ;
    }
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    
    [dic setObject:[Common getLoginInfo][@"userId"] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][@"userId"] forKey:@"msadMemberId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
    
    NSString * lan = [InternationalControl userLanguage];
    if ([lan isEqualToString:@"en"]) {
        [dic setObject:@"2" forKey:@"language"];
    }else{
        [dic setObject:@"1" forKey:@"language"];
    }
    [dic setObject:_stoneId forKey:@"msfoId"];
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:GS_queryStoreForeignMore withHttpType:@"POST" withTag:GS_GS_queryStoreForeignMore];
    
}

#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    if (tag == GS_GS_queryStoreForeignMore) {
        if (  [[database valueForKey:@"flag"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            
        }else  {
            if(![database[@"result"] isEqual:[NSNull null]]){
                NSDictionary * dic= database[@"result"];
                _productAddress.text = [NSString stringWithFormat:@"%@",dic[@"msfeOrigin"]];
                _detailAddress.text = [NSString stringWithFormat:@"%@",dic[@"msfeAddress"]];
                _nearAddress.text = [NSString stringWithFormat:@"%@",dic[@"msfePorts"]];
                _transType.text = [NSString stringWithFormat:@"%@",dic[@"msfeTransport"]];
                _phone = [NSString stringWithFormat:@"%@",dic[@"msfePhone"]];
                _phoneLabel.text = [NSString stringWithFormat:@"联系电话:%@",_phone];
            }
           
        }
    }
}

-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
